{extend name="light-year/layout/default" /}

{block name="title"}省市区管理{/block}

{block name="content"}
<div class="card-toolbar clearfix">
    <?php $parent_id = input('parent_id', 0); ?>
    <div class="toolbar-btn-action">
        <a class="btn btn-primary m-r-5" href="{:url('detail') }"><i class="mdi mdi-plus"></i> 新增 </a>
        {if !empty($parent_id)}
            <a class="btn btn-info m-r-5" href="{:url('detail', ['parent_id' => $parent_id]) }">
                <i class="mdi mdi-plus"></i>
                添加当前主栏目的下级
            </a>
        {/if}
        <a class="btn btn-danger" href="javascript:;" onclick="batchDelOperation('{:url(\'delete\')}');">
            <i class="mdi mdi-window-close"></i> 批量删除
        </a>
        <a class="btn btn-warning" href="{:url()}"><i class="mdi mdi-block-helper"></i> 重置 </a>
    </div>
</div>
<div class="card-body">
    <div class="table-responsive">
        <table class="table table-bordered">
            <thead>
            <tr>
                <th class="text-center">
                    <label class="lyear-checkbox checkbox-primary">
                        <input type="checkbox" id="check-all"><span></span>
                    </label>
                </th>
                <th class="text-center"> Id </th>
                <th class="text-center"> 名称 </th>
                <th class="text-center"> 层级 </th>
                <th class="text-center hidden-sm hidden-xs hidden-md"> 创建时间 </th>
                <th class="text-center"> 操作 </th>
            </tr>
            </thead>
            <tbody>
            {if !empty($list) && $list->total()}
            {foreach $list as $key => $item}
            <tr id="id_{$item->region_id}" name="{$item->name}">
                <td class="text-center">
                    <label class="lyear-checkbox checkbox-primary">
                        <input type="checkbox" name="region_id[]" value="{$item->region_id}"><span></span>
                    </label>
                </td>
                <td class="text-center"> <a href="javascript:;">{$item->region_id}</a> </td>
                <td class="text-center"> {$item->name} </td>
                <td class="text-center">
                    {switch $item->level|intval}
                    {case 1}
                    省份
                    {/case}
                    {case 2}
                    城市/直辖市
                    {/case}
                    {case 3}
                    区/县
                    {/case}
                    {/switch}
                </td>
                <td class="text-center hidden-sm hidden-xs hidden-md">
                    {:date('Y-m-d H:i', $item->created_time)}
                </td>
                <td class="text-center">
                    <div class="hidden-sm hidden-xs action-buttons">
                        {if $item->level < 3}
                        <a class="btn btn-xs btn-success" title="查看“{$item->name}”的下级" href="{:url('', ['parent_id' => $item->region_id])}">
                            <i class="mdi mdi-eye"></i> 查看下级
                        </a>
                        {/if}
                        <a class="btn btn-xs btn-info" title="编辑“{$item->name}”" href="{:url('detail', ['region_id' => $item->region_id])}">
                            <i class="mdi mdi-pencil"></i>
                            编辑
                        </a>
                        <a class="btn btn-xs btn-danger" title="删除“{$item->name}”" onclick="delOperation({$item->region_id}, '{:url(\'delete\')}')">
                            <i class="mdi mdi-window-close"></i>
                            删除
                        </a>
                    </div>
                    <div class="hidden-md hidden-lg">
                        <div class="inline position-relative">
                            <button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown" data-position="auto">
                                <i class="mdi mdi-settings small"></i>
                            </button>
                            <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                                {if $item->level < 3}
                                    <li>
                                        <a class="btn btn-xs btn-success" title="查看“{$item->name}”的下级" href="{:url('', ['parent_id' => $item->region_id])}">
                                            <i class="mdi mdi-eye"></i> 查看下级
                                        </a>
                                        <hr>
                                    </li>
                                {/if}
                                <li>
                                    <a class="btn btn-xs btn-info" title="编辑“{$item->name}”" href="{:url('detail', ['region_id' => $item->region_id])}">
                                        <i class="mdi mdi-pencil"></i>
                                        编辑
                                    </a>
                                    <hr>
                                </li>
                                <li>
                                    <a class="btn btn-xs btn-danger" title="删除“{$item->name}”" onclick="delOperation({$item->region_id}, '{:url(\'delete\')}')">
                                        <i class="mdi mdi-window-close"></i>
                                        删除
                                    </a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </td>
            </tr>
            {/foreach}
            {else/}
            <tr class="text-center">
                <td colspan="100"> 暂无数据！ </td>
            </tr>
            {/if}
            </tbody>
        </table>
    </div>
    {if !empty($list) && $list->total()}
        <hr>
        <div id="pageList" class="float-right">
            {$list|raw}
        </div>
        <div class="clearfix"></div>
    {/if}
</div>
{/block}

{block name="script-src"}
{/block}

{block name="script"}
<script type="text/javascript">

</script>
{/block}